<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录</title>
</head>
<body>
	<form action="/test/login.jsp" method="post">
		<p>
			<label>用户名</label>
			<input type="text" placeholder="请输入用户名" name="username" id="user"> 
		</p>
		<p>
			<label>密码</label>
			<input type="text" placeholder="请输入密码" name="password" id="pass"> 
		</p>
		<p>
            <input type="submit" value="登录">
            <input type="reset" value="重置">
            <input type="checkbox" name="remember" id="box">记住密码
        </p>
	</form>
	<script>
	function delCookie(name){
	    var exp = new Date();
	    exp.setTime(exp.getTime() - 1);
	    var cval=getCookie(name);
	    if(cval!=null)
	    document.cookie= name + "="+cval+";expires="+exp.toGMTString();
	}
        (function () {
            //获取浏览器储存的cookie
            //cookies是string类型
            var cookies = document.cookie;
            var arr = cookies.split(";");
            var len = arr.length;
            for (var i =0;i<len;i++){
                if (arr[i].indexOf("username=")>=0) {
                    var username = arr[i].substr("username=".length,arr[i].length);
                    document.getElementById("user").value = username;
                }
                if (arr[i].indexOf("password=")>=0) {
                    var password = arr[i].substr("password=".length+1,arr[i].length);
                    document.getElementById("pass").value = password;
                    document.getElementById("box").checked=true;
                }
            }       
        })();
    </script>
	
</body>
</html>